import Axios from 'axios'
// https://uat.ripple-corp.com
//https://campaign.chanel.com.cn
/* eslint-disable */
const Api = Axios.create({
  baseURL: process.env.NODE_ENV === 'development'
    ? 'https://hydrabeautysampling.chanel.com.cn'
    : '/',
  headers: {
    'Content-Type': 'application/json; charset=utf-8',
    'Access-Control-Allow-Origin': '*'
  }
});

Api.interceptors.response.use(function (response) {
  if (response.data.code === '00000' || response.data.code === '0000') {
    return response.data;
  }
  return Promise.reject(response.data);
}, function (error) {
  error.message = '网络错误';
  return Promise.reject(error);
});

export function getCrmUser(data) {
  return Api.post('/hydra-beauty-sample-user-api/get_crm_user', data)
}
export function sendCode(data) {
  return Api.post('/hydra-beauty-sample-user-api/send_auth_code', data)
}

export function getCheckInfo(data) {
  return Api.post('/hydra-beauty-sample-user-api/check', data)
}

export function userRegister(data) {
  return Api.post('/hydra-beauty-sample-user-api/register', data)
}

export function checkMobild(data) {
  return Api.post('/hydra-beauty-sample-user-api/is_exists', data)
}

export function getMax(data) {
  return Api.post('/hydra-beauty-sample-user-api/get_max', data)
}

export function testClearData(data) {
  return Api.post('/hydra-beauty-sample-user-api/clear', data)
}

export function wxShareApi(data) {
  // return Api.post('/wechat-obtain/evidence/signature', data)
}
export function getLimit() {
  return Api.get('/hydra-beauty-sample-user-api/get_limits')
}

export const responseJson = {
  "10011": "参数错误",
  "10002": "手机号码已注册",
  "10012": "验证码超时",
  "10013": "验证码错误",
  "10004": "未找到数据",
  "10003": "活动结束"
}
